<template>
    <div>
        <h2>登录</h2>
        <table class="table  table-bordered">
            <tbody>
                <tr>
                    <td>账号</td>
                    <td>
                        <input type="text" v-model="model.UserName">
                    </td>
                </tr>


                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="model.Password">
                    </td>
                </tr>


                <tr>
                    <td></td>
                    <td>
                        <input type="button" class="btn btn-success" value="登录" @click="ok">
                    </td>
                </tr>

            </tbody>


        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
const route = useRoute();
const router = useRouter();

//登录
let model = reactive({
    "UserName": '',
    "Password": '',
})



//登录
const ok=()=>{

axios({

url:'https://localhost:7259/api/HouseType/Login',
method:'post',
data:model,
})

.then((res)=>{
    console.log(res);
    if(res.data==0){
        alert("用户不存在");
        return;
    }
    else if(res.data==-1){
        alert("密码错误");
        return;
    }
    else{
        alert("登录成功");
        router.push('/HouseTypeAdd')
       
    }
})


.catch((ree)=>{
    console.log(ree);
})



}







</script>

<style scoped></style>